<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<%--<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>DICT智慧展示页面</title>
    <link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
    <link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
    <link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
    <link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
    <link rel="stylesheet" type="text/css"	href="../../static/js/WdatePicker/skin/WdatePicker.css">
    <link href="../../static/css/uploadify.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../static/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../static/js/detailview/datagrid-detailview.js"></script>
    <script type="text/javascript" src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../static/js/index.js"></script>
    <script type="text/javascript" src="../../static/js/WdatePicker/WdatePicker.js"></script>
    <script src="../../static/js/jquery.uploadify.js" type="text/javascript"></script>
    <%
        String pageNo=request.getParameter("pageNo");
        if(pageNo==null){
            pageNo="1";
        }
        String []nonceObj=ConstantUtils.getNonceObject();
    %>
    
    <script type="text/javascript">
    
        jQuery(document).ready(function(){
            $('#tm').dialog({
                onClose:function(){
                    gotoSearch($('#easyui-treegrid'));
                }
            });
        });
        
        var queryParams;
        function EasyuiDatagrid() {
            $("#easyui-datagrid").datagrid({
                url: '../../industry/DICT/selectDictTotalOrder.do',
                nowrap: true,
                striped: true,
                border: false,
                fit: true,
                rownumbers:true,
                queryParams: getGueryParams(),
                columns: [[
                    {field:'f_sd_code',checkbox:true},
                    {field:'f_sd_uid',title:'用户编号',align:'center',width:100},
                    {field:'f_sd_atArea',title:'用户居住地区',align:'center',width:150},
                    {field:'f_sd_village',title:'用户居住小区',align:'center',width:150},
                    // {field:'f_sd_address',title:'用户地址',align:'center',width:150},
                    {field:'f_sd_surname',title:'用户姓氏',align:'center',width:150},
                    {field:'f_sd_sex',title:'用户性别',align:'center',width:150},
                    {field:'f_sd_phone',title:'用户联系方式',align:'center',width:150},
                    {field:'f_sd_buyTime',title:'用户下单时间',align:'center',width:150},
                    {field:'f_sd_utMoney',title:'用户当日下单总额',align:'center',width:150},
                    {field:'f_sd_type',title:'操作',align:'center',width:350,
                        formatter:function(value,row,index){
                            str ="";
                            str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="onClickBtnDelete(\''+row.f_sd_oid+'\',\''+row.f_sd_isTotal+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-remove l-btn-icon-left">删除</span></span></a>';
                            str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="updateUser(\''+row.f_sd_uid+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">修改用户信息</span></span></a>';
                            str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="showUser(\''+row.f_sd_uid+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-search l-btn-icon-left">用户详情</span></span></a>';
                            str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="showOrders(\''+row.f_sd_oid+'\',\''+row.f_sd_uid+'\',\''+row.f_sd_village+'\',\''+row.f_sd_buyTime+'\',\''+row.f_sd_orderid+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-search l-btn-icon-left">订单详情</span></span></a>';
                            return str;
                        }
                    }
                ]],
                singleSelect:false,
                pagination:true,
                pageList:[10,20,30,40,50],
                pageSize:10,
                toolbar: '#toolbar',
                
                onExpandRow: function(index,row){
                
                },
                onSelect: function(rowIndex,rowData) {
                
                },
                onUnselect: function(rowIndex,rowData) {
                
                },
                onCheckAll: function(rowIndex,rowData) {
                
                },
                onUncheckAll: function(rowIndex,rowData) {
                
                },
                onLoadSuccess: function(data) {
                    if(data.total==-1) {
                        $.messager.defaults={ok:"确定",cancel:"取消"};
                        $.messager.confirm('提示', '用户尚未登录,请登录', function(r){
                            if (r){
                                window.parent.location.href='/login.do';
                                return false;
                            }});
                    }
                }
            });
        }

        function getGueryParams(){
            return {
                f_sd_village:$("#f_sd_village").val(),
                f_sd_atArea:$("#f_sd_atArea").val(),
                f_sd_surname:$("#f_sd_surname").val(),
                f_sd_sex:$("#f_sd_sex").val(),
                f_sd_buyTime:$("#f_sd_buyTime").val()
            };
        }
        
        $(function(){
            // new EasyuiDatagrid();
            onClickBtnDelete = function(id,tid){
                $.messager.confirm('确定删除内容','确定删除内容么?',function(r){
                    if(r){
                        app_ajax('../../industry/DICT/deleteOrder.do?f_sd_oid='+id+'&f_sd_isTotal='+tid,
                            '',
                            function(msg){
                                if(msg.success) {
                                    alert("删除成功!");
                                    if (checkAjaxRequestValidity(msg)) {
                                        gotoSearch($('#easyui-treegrid'));
                                        window.location.reload();
                                    }
                                } else {
                                    alert("删除异常，请联系管理员");
                                    if($.isFunction(window.showMessager)){
                                        window.showMessager(msg.resultTitle,msg.result);
                                    }
                                }
                            }
                        );
                    }
                });
            };
        });
        
        function SubgridTabOnSelect(title,index){
            setTimeout(function(){
                $("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
            },300);
            setTimeout(function(){
                $("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
            },3000);
        }
        
        function load(){
            $(".datagrid-row-expander datagrid-row-expand").attr("display","none");
        }
        
        function onpress(){
            var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
            if (event.keyCode == 13){
                gotoSearch($('#easyui-treegrid'));
            }
        }
        
        function showOrders(id,uid,village,time,orderid){
            openDialog($('#tm'),'show_order_list.jsp?f_sd_oid='+id+"&f_sd_uid="+uid+"&f_sd_village="+village+"&f_sd_buyTime="+time+"&f_sd_orderid="+orderid);
        }
        function showUser(id){
            openDialog($('#dlgs'),'show_userInfo.jsp?f_sd_uid='+id);
        }
        function updateUser(id){
            openDialog($('#dlgu'),'update_userInfo.jsp?f_sd_uid='+id);
        }
        function add(){
            openDialog($('#dlga'),'insert_userInfo.jsp');
        }
        $(function(){
            new EasyuiDatagrid();
            gotoSearch = function(){
                $("#easyui-datagrid").datagrid('reload',getGueryParams());
            };
        });

        $(function(){
            $('#win').window({
                onBeforeClose:function(){
                    //window.location.reload();
                    gotoSearch($('#easyui-treegrid'));
                }
            });
            initFileUpload("#uploadFile2", {});
        });
        function batch_add(){
            $('#win').window('open');
            $("winCss").attr("display","block");
        }
        function initFileUpload(inputId, params){
            var action = '../../industry/DICT/insertOrders.do;jsessionid='+$("#sessionId").val();
            $(inputId).uploadify({
                'swf'           :'../../swf/uploadify.swf',
                'uploader'      :action,
                'formData'      :params,
                'fileObjName'   :'uploadify',
                'cancelImg' 	:"../../imgs/uploadify-cancel.png",
                'queueId'		:"fileQueue",
                'fileTypeDesc'  :"Excel File",
                'fileTypeExts'	:"*.xls; *.xlsx",//限制文件类型
                'auto'			:true,//是否自动上传
                'multi'			:false,//是否允许多文件上传
                'buttonText'	:"导入文档",
                'method'		:"POST",
                'successTimeout':1200,
                'onInit'        : function(){
                },
                'onUploadStart' : function(file){
                    jQuery.messager.alert('批量导入','批量导入开始, 操作结果请稍后.');
                },
                'onUploadSuccess' : function(file,data,response) {
                    if(data != null && data != undefined && data != ''){
                        jQuery.messager.alert('批量导入',data);
                    }
                },
                'onUploadError' : function(file, errorCode, errorMsg, errorString) {
                    if(errorMsg == '302'){
                        jQuery.messager.alert('批量导入','批量导入失败，请检查登录状态或者无此权限!');
                    }
                }
            });
        }
        
    </script>
</head>
<body onload="load();">
<table id="easyui-datagrid" title="用户每日订单列表"></table>
<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
<div id="toolbar" class="easyui_datagrid_toolbar" style="">

    <div class="easyuiSearch">
        <form onsubmit="return false;" method="post" id="selectForm">
            <table cellspacing="0" cellpadding="0" width="90%">
                <tr>
                    <td align="left" width="5%">居住小区:</td>
                    <td align="left" width="13%"><input name="f_sd_village" id="f_sd_village" style="width: 150px;" onkeydown="onpress();" /></td>
                    <td align="left" width="5%">居住区域:</td>
                    <td align="left" width="13%">
                        <select id="f_sd_atArea" name="f_sd_atArea">
                            <option value="">请选择</option>
                            <option value="上城区">上城区</option>
                            <option value="拱墅区">拱墅区</option>
                            <option value="西湖区">西湖区</option>
                            <option value="滨江区">滨江区</option>
                            <option value="萧山区">萧山区</option>
                            <option value="余杭区">余杭区</option>
                            <option value="临平区">临平区</option>
                            <option value="钱塘区">钱塘区</option>
                            <option value="富阳区">富阳区</option>
                            <option value="临安区">临安区</option>
                            <option value="建德市">建德市</option>
                            <option value="桐庐县">桐庐县</option>
                            <option value="淳安县">淳安县</option>
                        </select>
                    </td>
                    <td align="left" width="5%">客户姓氏:</td>
                    <td align="left" width="13%"><input name="f_sd_surname" id="f_sd_surname" style="width: 150px;" onkeydown="onpress();" /></td>
                    <td align="left" width="5%">客户性别:</td>
                    <td align="left" width="13%">
                        <select id="f_sd_sex" name="f_sd_sex">
                            <option value="">请选择</option>
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </td>
                    <td align="left" width="5%">购买时间:</td>
                    <td align="left" width="13%"><input name="f_sd_buyTime" onClick="WdatePicker()" id="f_sd_buyTime" style="width: 150px;" /></td>
                    <td align="left" width="10%">
                        <limits:uiAuth url="selectDictTotalOrder.do">
                            <a href="javascript:void(0);" class="easyui-linkbutton"
                               data-options="iconCls:'icon-search', plain:true"
                               onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
                        </limits:uiAuth>
                    </td>
<%--                    <td align="left" width="20%">--%>
<%--                        <a href="javascript:void(0);" class="easyui-linkbutton"--%>
<%--                           data-options="iconCls:'icon-add', plain:true" onclick="batch_add()">批量上传</a>--%>
<%--                    </td>--%>
                </tr>
            </table>
        </form>
    </div>
    
    <div>
        <a href="javascript:void(0);" class="easyui-linkbutton"	data-options="iconCls:'icon-add', plain:true" onclick="add()">添加下单用户信息</a>
        <a href="javascript:void(0);" class="easyui-linkbutton"
           data-options="iconCls:'icon-add', plain:true" onclick="batch_add()">批量上传</a>
    </div>

</div>

<div id="dlgs" class="easyui-dialog"	style="width: 700px; height: 500px; padding-top: 0px;"
     data-options="title:'下单客户详情', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
    <iframe scrolling="auto" frameborder="0" style="width: 100%; height: 99%;"></iframe>
</div>
<div id="dlgu" class="easyui-dialog"	style="width: 700px; height: 500px; padding-top: 0px;"
     data-options="title:'修改客户信息', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
    <iframe scrolling="auto" frameborder="0" style="width: 100%; height: 99%;"></iframe>
</div>
<div id="dlga" class="easyui-dialog"	style="width: 700px; height: 500px; padding-top: 0px;"
     data-options="title:'添加客户信息', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
    <iframe scrolling="auto" frameborder="0" style="width: 100%; height: 99%;"></iframe>
</div>
<div id="tm" class="easyui-dialog"	style="width: 1200px; height: 650px; padding-top: 0px;"
     data-options="title:'子订单详情列表', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
    <iframe scrolling="auto" frameborder="0" style="width: 100%; height: 99%;"></iframe>
</div>

<div id="winCss" style="display: none">
    <div id="win" class="easyui-window" closed="true" modal="true" iconCls="icon-save" style="width:440px; height: 290px; left: 50%;top: 30%; title:'批量导入' ">
    <div  class="easyui-layout" fit="true">
    
        <div region="north" border="true" style="height: 40px;">
            <a class="easyui-linkbutton" style="line-height: 20px; padding-bottom: 3px;" iconCls="icon-undo" plain="true" href="../../static/excel/订单导入模板.xlsx">下载模版&nbsp;</a>
        </div>
        
        <div region="center" border="true">
            <div>
                <p>
                    <font size="6" style="font-weight: bold;color: gray;">批量导入说明:</font><br/>
                    &nbsp;&nbsp;这里是批量导入说明:<br/>
                </p>
            </div>
        </div>
        <div region="south" border="false" style="text-align:left;height:40px;padding: 3px">
            <input id="uploadFile2"  type="file" name="file"/>
        </div>
    
    </div>
</div>

</div>
</div>

</head>

</body>
</html>
